# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from decimal import Decimal
from typing import Union
from fastapi import Query
from pydantic import BaseModel, Field


class BillSearchIn(BaseModel):
    """ 账单搜索参数 """
    page_no: int = Query(default=1, gt=0, description="当前页码")
    page_size: int = Query(default=15, gt=0, description="每页条数")
    start_time: Union[int, str, None] = Query(default=None, description="开始时间")
    end_time: Union[int, str, None] = Query(default=None, description="结束时间")


class RechargePlaceIn(BaseModel):
    """ 充值下单参数 """
    package_id: int = Field(gt=0, description="充值套餐ID")

    class Config:
        json_schema_extra = {
            "example": {
                "package_id": 1
            }
        }

    @classmethod
    def messages(cls):
        return {
            "package_id.gt": "请正确选择套餐"
        }


"""--------------- Separator ---------------"""


class RechargePackageVo(BaseModel):
    """ 充值套餐列表Vo """
    id: int = Field(description="ID")
    name: str = Field(description="套餐名称")
    tags: str = Field(description="套餐标签")
    sell_price: Decimal = Field(max_digits=10, decimal_places=2, description="销售价格")
    line_price: Decimal = Field(max_digits=10, decimal_places=2, description="划线价格")
    points_num: int = Field(default=0, description="积分数量")
    train_num: int = Field(default=0, description="训练组数量")
    robot_num: int = Field(default=0, description="智能体数量")
    know_num: int = Field(default=0, description="知识库数量")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "name": "0.01",
                "tags": "限时优惠",
                "sell_price": 10.88,
                "line_price": 168.80,
                "points_num": 0,
                "train_num": 0,
                "robot_num": 0,
                "know_num": 0
            }
        }


class RechargePlaceVo(BaseModel):
    """ 充值下单结果Vo """
    order_id: int = Field(description="ID")
    paid_amount: Decimal = Field(description="应付金额")

    class Config:
        json_schema_extra = {
            "example": {
                "order_id": 1,
                "paid_amount": 0.01
            }
        }


class RechargeBillingVo(BaseModel):
    """ 充值账单记录Vo """
    order_sn: str = Field(description="订单编号")
    pay_way: str = Field(description="支付方式")
    pay_status: str = Field(description="支付状态")
    package_name: str = Field(description="套餐名称")
    points_num: int = Field(description="积分数量")
    train_num: int = Field(description="训练组数")
    robot_num: int = Field(description="智能体数")
    know_num: int = Field(description="知识库数")
    order_amount: Decimal = Field(max_digits=10, decimal_places=2, default=0, description="订单金额")
    paid_amount: Decimal = Field(max_digits=10, decimal_places=2, default=0, description="支付金额")
    pay_time: str = Field(description="支付时间")
    create_time: str = Field(description="创建时间")

    class Config:
        json_schema_extra = {
            "example": {

            }
        }
